//
// Created by hjie on 23-10-2.
//

#pragma once

#include <cstring>
#include <string>
#include <iostream>
#include <unistd.h>
extern "C"
{
#include <libavutil/threadmessage.h>
#include <libavutil/frame.h>
#include <libavutil/time.h>
#include <libavcodec/packet.h>
};

class PacketMessageQueue
{
public:
    PacketMessageQueue();
    ~PacketMessageQueue();
public:
    bool InitMessageQueue(int size);
    int  PushPacket(AVPacket ** packet);
    int  PopPacketNonBlocking(AVPacket ** packet);
    int  PopPacket(AVPacket ** packet);
    int  GetSize();
    void SetQueueEof();
private:
    AVThreadMessageQueue * m_thread_msg_queue;
};

class FrameMessageQueue
{
public:
    FrameMessageQueue();
    ~FrameMessageQueue();
public:
    bool InitMessageQueue(int size);
    int  PushFrame(AVFrame ** frame);
    int  PopFrameNonBlocking(AVFrame ** frame);
    int  PopFrame(AVFrame ** frame);
    int  GetSize();
private:
    AVThreadMessageQueue * m_thread_msg_queue;
};


